home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
batch
/
xset260.zip
/
XSET.DOC
< prev
next >
Wrap
Text File
|
1992-08-01
|
21KB
|
570 lines
┌──────────────────────────────────────────────────────────────┐
│ ENHANCED SET INSTRUCTION 2.60 - (C) 1992 STERN Marc │
└──────────────────────────────────────────────────────────────┘
All you always wanted to put in an environment variable and
never dare to ask DOS for...
XSET: The way to easily write efficient batch files.
XSET allows you to put EVERYTHING you want in a variable of
the current environment and use it as if you gave it the value with
the standard DOS command 'SET'. You will be able to write very efficient
batch files including string manipulation, calculation,...
XSET is the more powerful environment variable manipulation
program you never saw. It also has the easiest and most intuitive
user interface it is possible to write.
XSET is fully compatible with MS-DOS 5.0, DR-DOS 6.0, NDOS & 4DOS 4.0 .
XSET has five major features:
════════════════════════════
- XSET permits to catch the output of any command (internal or external)
or program and put it into an environment variable.
- XSET has several built-in commands to modify the output of a program
or a string given on the command-line (extract a part of a string,...)
- XSET has a built-in full floating-point calculation functionalitie:
──────────────────────────────────────────────
You can make incremental loops, input a calculation string and
output a number,...
- XSET can manage variable contents of more than 128 characters
(your path can now be as long as you want)
- XSET has some other built-in commands to give you access to some
system datas (date, time, ...)
* type XSET with no parameters to have the full description
of all functionalities (parameters and effects).
Example of use:
══════════════
Rem: in all the examples, the command XSET and the its built-in commands
are typed in uppercase and the environment variables names are
in lowercase. This is only for readability; when you type it,
you may mix lowercases and uppercase as you want.
The case is only significant for arguments strings you enter on the
command-line.
1) XSET datvar DATE
Puts the date into the variable 'datvar'
Type the command SET and you will see all the environment variables:
...
COMSPEC=...
DATVAR=dd-mm-yy (where dd,mm,yy are replaced by current
day, month and year)
...
You can now use the variable 'datvar' in a batch file:
ECHO the date is %datvar%
2) XSET name INPUT "Enter your name: "
Inputs a string from the keyboard (usual answer terminated by <Enter>)
and puts it into the variable 'name'.
You can now use the variable 'name' in a batch file to enter
personal environment for each user:
ECHO Hello %name%, beginning the work
CD \%name%
3) You can write a batch file with automatic loops
rem ------------------
set loop=1
:next
.......
anything you want
.......
XSET loop MATH %loop% + 1
if not %loop% == 20 goto next
rem ------------------
4) You can write a batch file where the user may enter
a calculation and use it as a number
rem ------------------
XSET calc INPUT "Enter your calculation: "
XSET result MATH %calc%
echo %calc% = %result%
rem ------------------
5) More complex example of a login procedure
rem ---------------------- LOGIN.BAT --------------------------------
echo off
cls
:N
rem Ask login name from keyboard
rem ----------------------------
XSET login INPUT "Enter login name : "
rem Test if directory corresponding to login name already exist
rem -----------------------------------------------------------
if exist c:\%login%\nul goto OK
rem Directory does not exist, ask to create it
rem ------------------------------------------
echo:
echo Login '%login%' does not exist.
echo Do you want to create it? (Y/N)
rem Only "yYnN" keys are allowed
rem ----------------------------
XSET ask KEY "yYnN"
rem Trick: if you use goto with a user input,
rem you don't have to take care of charcter-case
rem as DOS command.com is case-insensitive.
rem Otherwise, transform the input in upper/lowercases.
rem ----------------------------------------------------------
goto %ask%
:Y
rem Create directory
rem ----------------
md c:\%login%
:OK
set ask=
rem Go to user's directory and branch to personal
rem batch file if any.
rem ---------------------------------------------
cd \%login%
if exist autouser.bat autouser.bat
rem -----------------------------------------------------------------
6) You may use only one password input for several network connections
rem -----------------------------------------------------------------
echo off
cls
rem Ask login name from keyboard
rem ----------------------------
XSET login INPUT "Enter login name : "
rem Ask password from keyboard
rem --------------------------
XSET passwd PASSWD "Enter password : "
rem Connection to several network nodes
rem -----------------------------------
net use node1 ... %login% %passwd%
net use node2 ... %login% %passwd%
net use node3 ... %login% %passwd%
rem Overwrite variable containing password (to be sure)
rem --------------------------------------
set passwd=something_longer_that_password_to_be_sure
rem Clear variable containing password (to free environment)
rem ----------------------------------
set passwd=
rem -----------------------------------------------------------------
7) And much more ...
Installation:
════════════
- XSET.EXE is ready to use; no installation,
but it is a SHAREWARE version.
- To get a registered version of XSET, print the XSET.REG file,
fill it and send it to me; you will then receive the password
mandatory to use the program REGISTER.
You will receive each new upgrade for free!!!
Problems:
════════
- If the size of your environment space is not big enough,
you will receive an error message
'XSET : not enough environment space.'
This is not a bug, it is because the environment space
reserved for the variables is too small.
You must increase it by modifying the line 'SHELL=...'
in your CONFIG.SYS. By default, DOS reserves 256 bytes
environment space; this is generally insufficient.
Try 640 bytes (or more if you need it) by adding '/e:640'
at the line 'SHELL=...'
ex: SHELL=COMMAND.COM /E:640 /P
If this problem is encountered in a secondary shell
(i.e. you run the batch file from a menu that runs
a secondary shell) here is a way to work around the
problem (this is a DOS problem that could be avoided
by the program that runs the secondary shell):
put in your AUTOEXEC.BAT a line such as:
SET TO_DELETE=something_very_long_to_be_sure_this_takes_very_much_space
and, before using variables in the secondary shell delete this
---------
variable with the command:
SET TO_DELETE=
An other way to work around this limitation is to patch the
COMMAND.COM; see file 'PATCH.DOS' for more explanation.
- If you use special characters like <>| you will have a problem
because COMMAND.COM interpretes these characters like redirection
commands before giving the control to the program you call.
This is a general DOS problem, but it is very easy to work around.
ex: XSET var MATH (1 + 3) > 2
Although you think you call XSET to check if 4 is greater
than 2, command.com interprets it as
"put into a file named 2 the result of 'XSET var MATH (1+3)'"
You will have the same result with '<' and '|'.
The best way to ensure that all special characters you use
will be given 'as is' to the program you call (XSET or another one)
is to enclose your strings between double quotes:
XSET var MATH "%loop% < (5 * 36)"
Be careful that a string between quotes is interpreted as one
unique parameter for the program. So do not write
XSET var "MATH %loop% < 5"
- If you want to use the character '%' in a batch file, remember
that this character is reserved for DOS environment variable;
so, if you want to use a 'real' % character, you have to write
'%%' in your batch file.
ex: XSET var MATH "%other_var% %% 7"
This line in a batch file will put into variable 'var'
the result of '(contents of variable other_var) modulus 7'.
Remark that the use of double quotes doesn't affect the way that
command.com interpretes the % character;
you must double the % character even if it is quoted.
Additional information: 32.2.427.98.52 (after 19h)
══════════════════════ or 32.2.525.63.32 (work hours)
E-mail: stern@mble.philips.be (internet)
see appendix for other networks
Syntax: XSET <dosvar> COMMAND [args..]
Commands Arguments Action and value assigned to <dosvar>
-------- --------- -------------------------------------
INPUT [prompt] echo <prompt> and read input from standard input
ex: XSET name INPUT Enter your name:
PASSWD [prompt] same as INPUT without echoing
APPEND {string} old value + <string>
ex: XSET path APPEND ;c:\msc600\bin;c:\msc600\binb
Rem: this allow you to bypass the 128 characters
limit of DOS
KEY string key pressed (must be in <string> if not empty)
ex: XSET k KEY 123aAbB
only keys 123aAbB are allowed
ex: XSET k KEY
all are allowed
LENGTH {string} number of characters in <string>
LEFT n {string} the leftmost <n> characters of <string>
ex: XSET var LEFT 3 abcdef
puts 'abc' in variable 'var'
MID m n {string} the <n> characters in <string> starting from the <m>th
RIGHT n {string} the rightmost <n> characters of <string>
UPPER {string} uppercase <string>
LOWER {string} lowercase <string>
CHANGE s1 s2 {s3} change <s1> by <s2> in <s3>
SEARCH str1 {str2} portion of <str1> matching <str2>
<str2> is a UNIX-like regular expression.
A regular expression is one or more occurrences of one or more
characters.
The following symbols are treated specially:
^ start of line $ end of line
. any character \ quote next character
* match zero or more time preceding character (or character set)
+ match one or more time preceding character (or character set)
[] set of characters ('^' means non-inclusion, '-' means range)
ex: [aeiou0-9] match a, e, i, o, u, and 0 thru 9
[^ae0-9] match anything but a, e and 0 thru 9
^a match any line beginning by 'a'
v$ match any line ending by 'v'
XSET t SEARCH "^T.*K$" "This line will be OK"
XSET t SEARCH "^T.*[1-9].*K$" "Warning: This line will not be OK"
XSET t SEARCH "^T.*K$" "This line will not be OK!"
XSET t SEARCH "^T.*K" "This line will be OK!"
XSET t SEARCH "T.*K$" "Warning: This line will be OK"
COUNT {string} the number of words in <string>
WORD n {string} pick the <n>-th word in <string>
LINE n read the <n>-th line from standard input
MATH {expr} result of calculation of expression <expr>
mathematical operators: + - * / () on floats
% on integers
logical operators: = < > <= >= <>
'*' is equivalent to 'and'
'+' is equivalent to 'or'
precedence: + and - have the highest precedence,
evaluation is performed from left to right.
ex: XSET var MATH 3+(2*5) + %new% + (%loop% <= 5)
MIN ┌{str1...strn} minimum or maximum of numbers or strings list
MAX └{num1...numn} (one string may not contain <space> or <tab>)
ex: XSET var MIN 3.6 4 9.02
ex: XSET var MAX 3.6 4 abc 3.9j
DATE system date (dd-mm-yy)
DAY day of the month (1-31)
MONTH month number (1-12)
YEAR system year (4 digits)
DAYOFWEEK day in the week ( 0 = sunday,... )
TIME system time (hh:mm:ss - 24h format)
HOUR system hour (0-24)
MINUTE system minutes (0-59)
SEC system seconds (0-59)
YYMMDD system date in 'yymmdd' format
DIFFDATE date1 date2 number of days between date1 and date2 (date2 - date1)
date format may be 'dd-mm-yy' or 'yymmdd'
(may also be mixed)
ex: XSET day_nb DIFFDATE 25-04-92 920508 will give
14 days between 24 april and 8 march.
BYTEFREE [drive] number of bytes free on specified (or current) drive
DENSITY [drive] drive density (360, 720, 1200, 1440 or 0)
DIR [drive] current directory of <drive> or current drive
FPATH {file} full pathname of a filename
FDRIVE {file} drive of a filename
FDIR {file} drive & directory of a filename
FEXT {file} extension of a file name (no period included)
FNAME {file} name of a file without extension
FXNAME {file} name & extension of a file
FSIZE {file} size of a file
FDATE {file} date of a file (dd-mm-yy)
FTIME {file} time of a file (hh:mm)
TRUENAME {file} full truename of a file
ERRORLEVEL errorlevel code of last command
Rem: This command is only valid for
- MS-DOS 3.20, 3.21, 3.30, 4.0, 4.01 & 5.0
- NDOS 6.0
Results are unpredictable under other OS
or command processor like 4DOS, DR-DOS,
PC-DOS,...
VARCOPY variable contents of DOS environment variable 'variable'
This is equivalent to 'set dosvar=%variable%'
but allows to copy variables bigger than 128
characters.
[...] are optional arguments.
If arguments {...} are missing, they are read from the standard input.
Non quoted arguments on command-line will be separated by 1 blank.
Rem: 'XSET var' is equivalent to 'XSET var INPUT'
or 'XSET var LINE 1'
and is more performant.
XSET /CLEAR will clear delete all variables from environment\r\n\n"
XSET /VIEW will show all variables from environment
Same as 'SET' command but show lines longer than 128 characters
XSET /VIEW var will show content of variable 'var'
This command is useful to use variables longer
than 128 characters.
As COMMAND.COM trucates all lines longer than 128
characters, you will not be able to use a command like
'XSET newpath APPEND ";%path%"'
if variable 'path' is longer than about 100 characters.
You can now type: 'XSET/VIEW path | XSET newpath APPEND'
XSET /LOAD' will load variables from standard input.
variables must have been saved with command 'XSET /VIEW'
ex: save variables with 'XSET /VIEW > SAVEFILE.VAR'
reload variables with 'XSET /LOAD < SAVEFILE.VAR'
XSET /SIZE display environment size and free size (in bytes).
You can exit the help screen at any time by hitting Escape or Ctrl-C.
APPENDIX: E-mail address from other sites
========
Rem: This list is obviously not complete and is given here only
as brute information. If you are connected to another network
or cannot reach internet with the following procedure, ask
your network manager.
internet : stern@mble.philips.be
bitnet : stern@mble.philips.be
aol : stern@mble.philips.be
att : internet!mble.philips.be!stern
applelink : stern@mble.philips.be@dasnet#
compuserve : >INTERNET:stern@mble.philips.be
connect : DASNET
(first line = "stern@mble.philips.be"@dasnet)
easynet : stern@mble.philips.be (from Ultrix)
easynet : stern%mble.philips.be@decwrl.dec.com (from Ultrix via IP)
easynet : DECWRL::"stern@mble.philips.be" (from Ultrix via Decnet)
easynet : nm%DECWRL::"stern@mble.philips.be" (from VMS)
envoy : [RFC-822="stern(a)mble.philips.be"]INTERNET/TELEMAIL/US
(for special characters, use @=(a), !=(b), _=(u),
any=(3 octal digits)
fidonet : send to UUCP gateway with
first line = "To: stern@mble.philips.be"
geonet : DASNET (subject line = "stern@mble.philips.be!subject")
gsfcmail : (SITE:SMTPMAIL,ID:<stern(a)mble.philips.be>)
or (C:USA,A:TELEMAIL,P:SMTPMAIL,ID:<stern(a)mble.philips.be>)
keylink : (C:au, A:telememo, P:oz.au, "RFC-822":
(continuing...) "Marc Stern <stern(a)mble.philips.be>")
(for special characters, use @=(a), !=(b), %=(p), "=(q)
mci : To: Marc Stern (EMS)
EMS: internet
MBx: stern@mble.philips.be
nasamail : (site:smtpmail,id:<stern(a)mble.philips.be>)
nsi : east::"stern@mble.philips.be"
or dftnic::"stern@mble.philips.be"
or nssdca::in%"stern@mble.philips.be"
or jpllsi::"stern@mble.philips.be"
omnet : type 'compose manual' at the prompt,
choose 'Internet address' option from the menu,
type 'stern@mble.philips.be'
sinet : M_MAILNOW::M_INTERNET::"stern@mble.philips.be"
or M_MAILNOW::M_INTERNET::mble.philips.be::stern
span : AMES::"stern@mble.philips.be
or HAMLET::"stern@mble.philips.be
or IO::"stern@mble.philips.be
or IUE::"stern@mble.philips.be
or JPLLSI::"stern@mble.philips.be
or NSFGW::"stern@mble.philips.be
or NSSDCA::"stern@mble.philips.be
or STAR::"stern@mble.philips.be
sprintmail : (C:USA,A:TELEMAIL,P:INTERNET,"RFC-822":
(continuing...) <stern(a)mble.philips.be>) DEL
thenet : UTADNX::WINS%" stern@mble.philips.be "
telemail : [INTERMAIL/USCISI]TELEMAIL/USA
with first line = Forward: ARPA
and second line = To: stern@mble.philips.be